<?php
namespace app\common\model;

class AttachmentModel extends BaseModel
{
    protected $name = 'attachment'; //定义用户表
    //开启自动写入时间戳
    protected $autoWriteTimestamp = false;
    // 定义自动完成的属性
    protected $auto = []; //新增修改
    protected $insert = []; //插入
    protected $update = []; //修改

    /*读取器*/
    protected function getUrlTextAttr($value, $data)
    {
        if (in_array($data['type'], [".png", ".jpg", ".jpeg", ".gif", ".bmp"])) {
            return '<a href="' . $data['url'] . '" target="_blank"><img src="' . $data['url'] . '" width="80" height="80" /></a>';
        } else {
            return '<a href="' . $data['url'] . '" target="_blank">查看附件</a>';
        }
    }
    /*修改器*/
}